package com.frank.service.nettydemo;

import io.netty.channel.nio.NioEventLoopGroup;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: huweifeng
 * @Date: 2025/2/7
 * @Description: Channel与EventLoop进行绑定
 **/
@Slf4j
public class EventLoopGroup {
    public static void main(String[] args) {
        // 内部创建2个EventLoop，每个EventLoop维护一个线程
        NioEventLoopGroup group = new NioEventLoopGroup(2);
        System.out.println(group.next());
        System.out.println(group.next());
        System.out.println(group.next());
        System.out.println(group.next());

        // 一个EventLoop进行 普通任务
        group.next().submit(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            log.info("ok");
        });
        log.debug("main");
    }
}
